{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "%matplotlib inline"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "\n#  Text properties and layout\n\n\nControlling properties of text and its layout with Matplotlib.\n\nThe :class:`matplotlib.text.Text` instances have a variety of\nproperties which can be configured via keyword arguments to the text\ncommands (e.g., :func:`~matplotlib.pyplot.title`,\n:func:`~matplotlib.pyplot.xlabel` and :func:`~matplotlib.pyplot.text`).\n\n==========================  ======================================================================================================================\nProperty                    Value Type\n==========================  ======================================================================================================================\nalpha                       `float`\nbackgroundcolor             any matplotlib :doc:`color </tutorials/colors/colors>`\nbbox                        `~matplotlib.patches.Rectangle` prop dict plus key ``'pad'`` which is a pad in points\nclip_box                    a matplotlib.transform.Bbox instance\nclip_on                     bool\nclip_path                   a `~matplotlib.path.Path` instance and a `~matplotlib.transforms.Transform` instance, a `~matplotlib.patches.Patch`\ncolor                       any matplotlib :doc:`color </tutorials/colors/colors>`\nfamily                      [ ``'serif'`` | ``'sans-serif'`` | ``'cursive'`` | ``'fantasy'`` | ``'monospace'`` ]\nfontproperties              a `~matplotlib.font_manager.FontProperties` instance\nhorizontalalignment or ha   [ ``'center'`` | ``'right'`` | ``'left'`` ]\nlabel                       any string\nlinespacing                 `float`\nmultialignment              [``'left'`` | ``'right'`` | ``'center'`` ]\nname or fontname            string e.g., [``'Sans'`` | ``'Courier'`` | ``'Helvetica'`` ...]\npicker                      [None|float|boolean|callable]\nposition                    (x, y)\nrotation                    [ angle in degrees | ``'vertical'`` | ``'horizontal'`` ]\nsize or fontsize            [ size in points | relative size, e.g., ``'smaller'``, ``'x-large'`` ]\nstyle or fontstyle          [ ``'normal'`` | ``'italic'`` | ``'oblique'`` ]\ntext                        string or anything printable with '%s' conversion\ntransform                   a `~matplotlib.transforms.Transform` instance\nvariant                     [ ``'normal'`` | ``'small-caps'`` ]\nverticalalignment or va     [ ``'center'`` | ``'top'`` | ``'bottom'`` | ``'baseline'`` ]\nvisible                     bool\nweight or fontweight        [ ``'normal'`` | ``'bold'`` | ``'heavy'`` | ``'light'`` | ``'ultrabold'`` | ``'ultralight'``]\nx                           `float`\ny                           `float`\nzorder                      any number\n==========================  ======================================================================================================================\n\n\nYou can lay out text with the alignment arguments\n``horizontalalignment``, ``verticalalignment``, and\n``multialignment``.  ``horizontalalignment`` controls whether the x\npositional argument for the text indicates the left, center or right\nside of the text bounding box. ``verticalalignment`` controls whether\nthe y positional argument for the text indicates the bottom, center or\ntop side of the text bounding box.  ``multialignment``, for newline\nseparated strings only, controls whether the different lines are left,\ncenter or right justified.  Here is an example which uses the\n:func:`~matplotlib.pyplot.text` command to show the various alignment\npossibilities.  The use of ``transform=ax.transAxes`` throughout the\ncode indicates that the coordinates are given relative to the axes\nbounding box, with 0,0 being the lower left of the axes and 1,1 the\nupper right.\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "import matplotlib.pyplot as plt\nimport matplotlib.patches as patches\n\n# build a rectangle in axes coords\nleft, width = .25, .5\nbottom, height = .25, .5\nright = left + width\ntop = bottom + height\n\nfig = plt.figure()\nax = fig.add_axes([0, 0, 1, 1])\n\n# axes coordinates are 0,0 is bottom left and 1,1 is upper right\np = patches.Rectangle(\n    (left, bottom), width, height,\n    fill=False, transform=ax.transAxes, clip_on=False\n    )\n\nax.add_patch(p)\n\nax.text(left, bottom, 'left top',\n        horizontalalignment='left',\n        verticalalignment='top',\n        transform=ax.transAxes)\n\nax.text(left, bottom, 'left bottom',\n        horizontalalignment='left',\n        verticalalignment='bottom',\n        transform=ax.transAxes)\n\nax.text(right, top, 'right bottom',\n        horizontalalignment='right',\n        verticalalignment='bottom',\n        transform=ax.transAxes)\n\nax.text(right, top, 'right top',\n        horizontalalignment='right',\n        verticalalignment='top',\n        transform=ax.transAxes)\n\nax.text(right, bottom, 'center top',\n        horizontalalignment='center',\n        verticalalignment='top',\n        transform=ax.transAxes)\n\nax.text(left, 0.5*(bottom+top), 'right center',\n        horizontalalignment='right',\n        verticalalignment='center',\n        rotation='vertical',\n        transform=ax.transAxes)\n\nax.text(left, 0.5*(bottom+top), 'left center',\n        horizontalalignment='left',\n        verticalalignment='center',\n        rotation='vertical',\n        transform=ax.transAxes)\n\nax.text(0.5*(left+right), 0.5*(bottom+top), 'middle',\n        horizontalalignment='center',\n        verticalalignment='center',\n        fontsize=20, color='red',\n        transform=ax.transAxes)\n\nax.text(right, 0.5*(bottom+top), 'centered',\n        horizontalalignment='center',\n        verticalalignment='center',\n        rotation='vertical',\n        transform=ax.transAxes)\n\nax.text(left, top, 'rotated\\nwith newlines',\n        horizontalalignment='center',\n        verticalalignment='center',\n        rotation=45,\n        transform=ax.transAxes)\n\nax.set_axis_off()\nplt.show()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#  Default Font\n\n\nThe base default font is controlled by a set of rcParams. To set the font\nfor mathematical expressions, use the rcParams beginning with ``mathtext``\n(see `mathtext <mathtext-fonts>`).\n\n+---------------------+----------------------------------------------------+\n| rcParam             | usage                                              |\n+=====================+====================================================+\n| ``'font.family'``   | List of either names of font or ``{'cursive',      |\n|                     | 'fantasy', 'monospace', 'sans', 'sans serif',      |\n|                     | 'sans-serif', 'serif'}``.                          |\n|                     |                                                    |\n+---------------------+----------------------------------------------------+\n|  ``'font.style'``   | The default style, ex ``'normal'``,                |\n|                     | ``'italic'``.                                      |\n|                     |                                                    |\n+---------------------+----------------------------------------------------+\n| ``'font.variant'``  | Default variant, ex ``'normal'``, ``'small-caps'`` |\n|                     | (untested)                                         |\n+---------------------+----------------------------------------------------+\n| ``'font.stretch'``  | Default stretch, ex ``'normal'``, ``'condensed'``  |\n|                     | (incomplete)                                       |\n|                     |                                                    |\n+---------------------+----------------------------------------------------+\n|  ``'font.weight'``  | Default weight.  Either string or integer          |\n|                     |                                                    |\n|                     |                                                    |\n+---------------------+----------------------------------------------------+\n|   ``'font.size'``   | Default font size in points.  Relative font sizes  |\n|                     | (``'large'``, ``'x-small'``) are computed against  |\n|                     | this size.                                         |\n+---------------------+----------------------------------------------------+\n\nThe mapping between the family aliases (``{'cursive', 'fantasy',\n'monospace', 'sans', 'sans serif', 'sans-serif', 'serif'}``) and actual font names\nis controlled by the following rcParams:\n\n\n+------------------------------------------+--------------------------------+\n| family alias                             | rcParam with mappings          |\n+==========================================+================================+\n| ``'serif'``                              | ``'font.serif'``               |\n+------------------------------------------+--------------------------------+\n| ``'monospace'``                          | ``'font.monospace'``           |\n+------------------------------------------+--------------------------------+\n| ``'fantasy'``                            | ``'font.fantasy'``             |\n+------------------------------------------+--------------------------------+\n| ``'cursive'``                            | ``'font.cursive'``             |\n+------------------------------------------+--------------------------------+\n| ``{'sans', 'sans serif', 'sans-serif'}`` | ``'font.sans-serif'``          |\n+------------------------------------------+--------------------------------+\n\n\nwhich are lists of font names.\n\nText with non-latin glyphs\n==========================\n\nAs of v2.0 the `default font <default_changes_font>` contains\nglyphs for many western alphabets, but still does not cover all of the\nglyphs that may be required by mpl users.  For example, DejaVu has no\ncoverage of Chinese, Korean, or Japanese.\n\n\nTo set the default font to be one that supports the code points you\nneed, prepend the font name to ``'font.family'`` or the desired alias\nlists ::\n\n   matplotlib.rcParams['font.sans-serif'] = ['Source Han Sans TW', 'sans-serif']\n\nor set it in your :file:`.matplotlibrc` file::\n\n   font.sans-serif: Source Han Sans TW, Arial, sans-serif\n\nTo control the font used on per-artist basis use the ``'name'``,\n``'fontname'`` or ``'fontproperties'`` kwargs documented :doc:`above\n</tutorials/text/text_props>`.\n\n\nOn linux, `fc-list <https://linux.die.net/man/1/fc-list>`__ can be a\nuseful tool to discover the font name; for example ::\n\n   $ fc-list :lang=zh family\n   Noto to Sans Mono CJK TC,Noto Sans Mono CJK TC Bold\n   Noto Sans CJK TC,Noto Sans CJK TC Medium\n   Noto Sans CJK TC,Noto Sans CJK TC DemiLight\n   Noto Sans CJK KR,Noto Sans CJK KR Black\n   Noto Sans CJK TC,Noto Sans CJK TC Black\n   Noto Sans Mono CJK TC,Noto Sans Mono CJK TC Regular\n   Noto Sans CJK SC,Noto Sans CJK SC Light\n\nlists all of the fonts that support Chinese.\n\n\n"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}
